package com.xiaolin.generic;

/**
 * @ClassName GenericInterface1Test
 * @Description 泛型接口实现方式 1
 * @Detail 使用泛型类去实现接口，即实现类可以存储任意一种类型的对象
 * @Author MyPC
 * @Date 2020/11/30
 * @Version 1.0
 */
public class GenericInterface1Test<T> implements GenericInterface<T>{

    private T data;

    @Override
    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static void main(String[] args) {
        GenericInterface1Test<Man> g=new GenericInterface1Test<>();
        Man man=new Man();
        man.setName("小林");
        g.setData(man);
        System.out.println(g.getData().getName());
    }
}

class Man{
    private String name;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}
